#include "opencv2/core/base.hpp"
#include "opencv2/core/cuda.hpp"
#include "opencv2/cudawarping.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"

int main(int argc, char** argv)
{
    if (argc != 2) {
        fprintf(stderr, "usage: %s PATH\n", argv[0]);
        return 1;
    }

    cv::Mat image = cv::imread(argv[1]);

    if (image.empty()) {
        fprintf(stderr, "imread: failed to read: %s\n", argv[1]);
        return 1;
    }

    cv::cuda::GpuMat image_gpu;
    image_gpu.upload(image);

    cv::cuda::GpuMat resized_image_gpu;
    cv::cuda::resize(image_gpu, resized_image_gpu, cv::Size(), 0.2, 0.2);

    cv::Mat resized_image;
    resized_image_gpu.download(resized_image);

    cv::imshow("resized", resized_image);
    cv::waitKey();

    return 0;
}
